package com.globalblue;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Calendar;

public class FolderManager {
	public void createFolderStructure(String baseFolder,String ticketId) {
		Calendar now = Calendar.getInstance();
		int year = now.get(Calendar.YEAR);
		String month = new SimpleDateFormat("MMM").format(now.getTime());
		createFolder(baseFolder);
		createFolder(baseFolder + "/" + year);
		createFolder(baseFolder + "/" + year + "/" + month);
		createFolder(baseFolder + "/" + year + "/" + month + "/" + ticketId);
	}

	public void createFolder(String path) {
		File theDir = new File(path);
		// if the directory does not exist, create it
		if (!theDir.exists()) {
			System.out.println("creating directory: " + path);
			boolean result = theDir.mkdir();

			if (result) {
				System.out.println("DIR created");
			}
		}
	}
}
